package com.linkhub.oms.admin.modules.user.accountflow.domain.vo;

import com.linkhub.oms.entity.EntryOrderLineEntity;
import com.linkhub.oms.entity.LocalProductEntity;
import com.linkhub.oms.entity.resulttype.order.OrderLocalProductDO;
import com.linkhub.oms.entity.resulttype.order.OrderShopProductDO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

/**
 * @author Redball
 * @version 1.0.0
 * @Description ProductListVo
 * @createTime 2024/8/1 上午1:17
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "ProductListVo", description = "商品清单")
@NoArgsConstructor
public class ProductListVo {

    @ApiModelProperty(value = "商品skuId")
    private String skuId;

    @ApiModelProperty(value = "sku")
    private String sku;

    @ApiModelProperty(value = "商品名称")
    private String productEnTitle;

    @ApiModelProperty(value = "商品数量")
    private Integer currentQuantity;

    public ProductListVo(OrderLocalProductDO orderLocalProductDO) {
        this.skuId = orderLocalProductDO.getSkuId();
        this.sku = orderLocalProductDO.getSku();
        this.productEnTitle = orderLocalProductDO.getProductEnTitle();
        this.currentQuantity = orderLocalProductDO.getCurrentQuantity();
    }

    public ProductListVo(OrderShopProductDO orderShopProductDO) {
        this.skuId = StringUtils.defaultIfBlank(orderShopProductDO.getLocalSkuId(), String.valueOf(orderShopProductDO.getSkuId()));
        this.sku = StringUtils.defaultIfBlank(orderShopProductDO.getLocalSku(),orderShopProductDO.getSku());
        this.productEnTitle = StringUtils.defaultIfBlank(orderShopProductDO.getLocalProductEnTitle(),orderShopProductDO.getTitle());
        this.currentQuantity = orderShopProductDO.getCurrentQuantity();
    }

    public ProductListVo(EntryOrderLineEntity entryOrderLine){
        this.skuId = entryOrderLine.getSkuId();
        this.sku = entryOrderLine.getSku();
        this.productEnTitle = entryOrderLine.getProductEnTitle();
        this.currentQuantity = entryOrderLine.getSkuQuantity();
    }

    public ProductListVo(LocalProductEntity localProduct, Integer currentQuantity){
        this.skuId = localProduct.getSkuId();
        this.sku = localProduct.getSku();
        this.productEnTitle = localProduct.getProductEnTitle();
        this.currentQuantity = currentQuantity;
    }
}
